﻿@*作业上交情况*@
@using EasyCourse.Model;
@{
    Layout = null;
    CommonPageInfo pageInfo = ViewData[CommonViewDataKey.CommonPageInfo] as CommonPageInfo;
    string para = "CourseId=" + pageInfo.CourseId;
}
@model VAssignmentInfo
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>作业提交情况</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav4Teacher.cshtml")
    <div class="container">
        <div class="row">
            <h1 class="topTitle-h1">@pageInfo.CourseName<br><small>广州中医药大学康复治疗微课程网络学习平台</small></h1>
        </div>
    </div>
    @*导航菜单*@
    @Html.Partial("~/Views/Share/PublicTeacherNaviMenu.cshtml", 1)
    <div class="container wrap1">
        <div class="row">
            <div class="col-xs-2">
                <div class="dropdown theme-dropdown clearfix">
                    <a id="dropdownMenu1" href="#" role="button" class="sr-only dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                        <li class="active" role="presentation">
                            <a role="menuitem" tabindex="-1" href="/AssignmentManage/List?@para">
                                <span class="glyphicon glyphicon-th-list"></span> 作业列表
                            </a>
                        </li>
                        <li role="presentation" class="divider"></li>
                        <li role="presentation">
                            <a role="menuitem" tabindex="-1" href="@Url.Action("Add", "AssignmentManage")?@para">
                                <span class="glyphicon glyphicon-plus"></span> 新增作业
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="col-xs-10">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            <ol class="breadcrumb">
                                <li>作业管理</li>
                                <li class="active">作业列表</li>
                            </ol>
                        </h3>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <form class="form-horizontal" role="form">
                                <div class="form-group clearfix">
                                    <label for="workName" class="col-xs-2 control-label">作业名称：</label>
                                    <div class="col-xs-3">
                                        <input type="text" value="@Model.Entity.Title" class="form-control" id="workName" disabled/>
                                    </div>
                                    <label for="stuGroup" class="col-xs-2 control-label">作业学生组：</label>
                                    <div class="col-xs-3">
                                        <input type="text" value="@Model.GroupName" class="form-control" id="workName" disabled/>
                                    </div>
                                    <div class="col-xs-2"></div>
                                </div>
                                <div class="form-group clearfix">
                                    <label for="submitSate" class="col-xs-2 control-label">提交情况：</label>
                                    <div class="col-xs-3">
                                        <select class="form-control" id="submitSate">
                                            <option value="-1" selected>全部</option>
                                            <option value="0">未提交</option>
                                            <option value="1">已提交</option>
                                        </select>
                                    </div>
                                    <label for="stuCode" class="col-xs-2 control-label">学号：</label>
                                    <div class="col-xs-3">
                                        <input type="text" class="form-control" id="stuCode" />
                                    </div>
                                    <div class=" col-xs-2">
                                        <button type="button" class="btn btn-success" id="subBtn">
                                            <span class="glyphicon glyphicon-search"></span> 搜索
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <table class="table table-bordered tb1 table-striped table-hover" id="tb">
                            <thead>
                                <tr>
                                    <th width="20%">姓名</th>
                                    <th width="20%">学号</th>
                                    <th width="10%">是否提交</th>
                                    <th width="30%">提交时间</th>
                                    <th width="20%">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                @*<tr>
                                    <td>曾文帜</td>
                                    <td>是</td>
                                    <td>2014-10-12</td>
                                    <td>
                                        <a class="operate" href="javascript:void(0)"><span class="glyphicon glyphicon-circle-arrow-down"></span> 下载作业</a>
                                    </td>
                                </tr>*@
                            </tbody>
                        </table>
                        <div class="row clearfix well" id="well">
                            <div class="pull-left sum" id="PagInfo"></div>
                            <div class=" center-block clearfix pull-right">
                                <ul class="pagination" id="PageTool"></ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicFooter.cshtml")
    @Html.Partial("~/Views/Share/PublicCommonJs.cshtml")
    <script>
        var _courseId = $.getUrlParam("CourseId"),     //课程id
            _assignmentId = $.getUrlParam("AssignmentId"),
            $stuCode,      //学号
            $submitSate,   //作业是否提交
            ele,           //表格内容区
            _courseName = "",   //课程名称
            _status = -1,  //为-1时默认全部加载
            _JlistTop,
            _state = false,
            opts = false;
        $(function () {
            _courseId =  $.getUrlParam("CourseId"),
            ele = $("#tb tbody"),
            $stuCode = $("#stuCode"),
            $submitSate = $("#submitSate");
            _JlistTop = $(".wrap1").offset().top - $(".topNavPar").height();
            $(window).scroll(function () {
                if ($(window).scrollTop() >= 300) {
                    $('.actGotop').fadeIn(300);
                } else {
                    $('.actGotop').fadeOut(300);
                }
            });
            $("#well").hide();;
            $('.actGotop').click(function () {
                $('html,body').animate({ scrollTop: '0px' }, 800);
            });
            getList(1);
            /*搜索时强制回到第一页*/
            $("#subBtn").click(function () { getList(1); });
        });
        /*获取表格数据*/
        function getList(pageNo) {
            _status = $submitSate.val(); 
            $.easyPost("/AssignmentManage/GetSubmitList", {
                "PageNO": pageNo,
                "PageSize": "10",
                "AssignmentId": _assignmentId,
                "Account": $stuCode.val().trim(),
                "IsSubmit": _status
            },
               function (data) {
                   var _html = ''
                   if (!data.result) {
                       showTips.open(data.message);
                       return;
                   }
                   if (data.rows.length > 0) {
                       var _row = data.rows,
                           _rowL = _row.length;
                       opts = {
                           totalPages: data.totalPage,
                           total: data.total,
                           currentPage: pageNo,
                           onPageClicked: function (event, originalEvent, type, page) {
                               getList(page);
                           }
                       }
                       initialPaginator(opts, "PageTool", "PagInfo");
                       for (var i = 0; i < _rowL; i++) {
                           var item = _row[i];
                           var state = ((item.IsSubmit == 1) ? "已提交" : "未提交");
                           var _date = "", time = "";
                           if (item.SubmitTime != null) {
                               _date = item.SubmitTime.replace(/\//g, "");
                               time = eval('new ' + _date).format("yyyy-MM-dd");
                           }
                           _html += '<tr>' +
                               '<td>' + item.RealName + '</td>' +
                               '<td>' + item.Account + '</td>' +
                               '<td>' + state + '</td>' +
                               '<td>' + time + '</td>' +
                               '<td><a class="operate" href="javascript:download(\'' + item.SubmitAssignmentId + '\')"><span class="glyphicon glyphicon-circle-arrow-down"></span> 下载作业</a></tr>';
                       }
                       if (_state) {
                           $('html,body').animate({ scrollTop: _JlistTop }, 0);
                       }
                       _state = true;
                       $("#well").show();

                   } else {
                       _html = "<tr><td colspan='5' align='center'>暂无内容!</tr>";
                       $("#well").hide();
                   }
                   //向tbody内部填充数据
                   ele.html(_html);
               }, "json");
        }
        //下载作业
        function download(id) {
            $.easyPost("@Url.Action("DownLoadAssignSub", "AssignmentManage")", { "SubmitId": id }, function (data) {
                if (data.result == false) {
                    showTips.open(data.message); return;
                }             
                window.location.href = data.entity;
            });
        }
    </script>
</body>
</html>
